package models.shared

import models.User

data class UserUi(
    val id: Int,
    val username: String,
    val role: UserUi.Role,
    val createdAt: Long,
    val location: models.LocationUi? = null
) {
    companion object {
        fun from(user: User): UserUi {
            return UserUi(
                user.id,
                user.username,
                UserUi.Role.valueOf(user.role.uppercase()),
                user.createdAt,
                user.location?.let(models.LocationUi.Companion::from)
            )
        }
    }

    enum class Role {
        USER,
        MODERATOR,
        ADMIN
    }
}